ea467d04b90d716d2960cc155c71533e05da1bfc,sonar-core/src/test/java/org/sonar/core/preview/PreviewCacheTest.java,PreviewCacheTest,test_getDatabaseForDryRun_global_invalidation,#,125
Before Change
return dbFile;
}
});
byte[] dbContent = dryRunCache.getDatabaseForPreview(null);
assertThat(new String(dbContent)).isEqualTo("fake db content 1");
// Emulate invalidation of cache
Thread.sleep(100);
when(propertiesDao.selectGlobalProperty(PreviewCache.SONAR_PREVIEW_CACHE_LAST_UPDATE_KEY)).thenReturn(new PropertyDto().setValue("" + System.currentTimeMillis()));
dbContent = dryRunCache.getDatabaseForPreview(null);
assertThat(new String(dbContent)).isEqualTo("fake db content 2");
verify(dryRunDatabaseFactory, times(2)).createNewDatabaseForDryRun(anyLong(), any(File.class), anyString());
After Change
return dbFile;
}
});
String path = dryRunCache.getPathToDatabaseFile(null);
assertThat(FileUtils.readFileToString(new File(path))).isEqualTo("fake db content 1");
// Emulate invalidation of cache
Thread.sleep(100);
when(propertiesDao.selectGlobalProperty(PreviewCache.SONAR_PREVIEW_CACHE_LAST_UPDATE_KEY)).thenReturn(new PropertyDto().setValue("" + System.currentTimeMillis()));
path = dryRunCache.getPathToDatabaseFile(null);
assertThat(FileUtils.readFileToString(new File(path))).isEqualTo("fake db content 2");
verify(dryRunDatabaseFactory, times(2)).createNewDatabaseForDryRun(anyLong(), any(File.class), anyString());